package setting

import "time"

var (
	Settings *SettingsS //所有的配置
)

// SettingsS 所有配置
type SettingsS struct {
	Server   *ServerSettingS   `mapstructure:"server"`
	Log      *LogSettingsS     `mapstructure:"log"`
	Database *DBSettingsS      `mapstructure:"database"`
	Redis    *RedisSettingsS   `mapstructure:"redis"`
	Payment  *PaymentSettingsS `mapstructure:"payment"`
	Jwt      *JwtSettingsS     `mapstructure:"jwt"`
}

// ServerSettingS 服务的基础配置
type ServerSettingS struct {
	RunMode      string        `mapstructure:"run_mode"`
	HttpHost     string        `mapstructure:"http_host"`
	HttpPort     string        `mapstructure:"http_port"`
	ReadTimeout  time.Duration `mapstructure:"read_timeout"`
	WriteTimeout time.Duration `mapstructure:"write_timeout"`
	RateLimit    int           `mapstructure:"rate_limit"`
}

// LogSettingsS 日志配置
type LogSettingsS struct {
	SavePath string `mapstructure:"savepath"`
	FileName string `mapstructure:"filename"`
	FileExt  string `mapstructure:"fileExt"`
}

// DBSettingsS 数据库配置
type DBSettingsS struct {
	Driver       string `mapstructure:"driver"`
	UserName     string `mapstructure:"username"`
	PassWord     string `mapstructure:"password"`
	Host         string `mapstructure:"host"`
	Port         int    `mapstructure:"port"`
	DB           string `mapstructure:"db"`
	Prefix       string `mapstructure:"prefix"`
	Charset      string `mapstructure:"charset"`
	ParseTime    bool   `mapstructure:"parseTime"`
	MaxIdleConns int    `mapstructure:"max_idle_conns"`
	MaxOpenConns int    `mapstructure:"max_open_conns"`
	MaxLifetime  uint8  `mapstructure:"max_lifetime"`
	Log          bool   `mapstructure:"log"`
}

// RedisSettingsS redis的配置
type RedisSettingsS struct {
	Addr string `mapstructure:"addr"`
	Auth string `mapstructure:"auth"`
	DB   int    `mapstructure:"db"`
}

// PaymentSettingsS 支付密钥配置
type PaymentSettingsS struct {
	SySecret string `mapstructure:"sySecret"`
}

type JwtSettingsS struct {
	Secret      string `mapstructure:"secret"`
	ExpiredHour int    `mapstructure:"expiredHour"`
}
